jsx3.Class.defineClass(
		"tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb", //the full name of the class to create
		jsx3.gui.Block, //  extends
		null, // implements
		function (plugin) {
			plugin.displayTypeService = 0;
			plugin.displayTypeServiceAssembly = 1;
			plugin.displayTypeServiceUnit = 2;
			plugin.displayTypeNode = 3;

			plugin.prototype.isLogical;
			plugin.prototype.displayType;
			plugin.prototype.infoCacheId;
			plugin.prototype.hideEnvironment;
			plugin.prototype.nameSuffix = "";

			plugin.logicalLabelText = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@breadCrumbLogicalLabel");
			plugin.physicalLabelText = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@breadCrumbPhysicalLabel");

			plugin.prototype.init = function() {
				this.jsxsuper();

			} ;

			plugin.prototype.getNamespace = function() {
				return "tibco.admin";
			} ;

			plugin.prototype.setUpComponent = function(nameSuffix, isLogical, displayType, infoCacheSubject, infoCacheId, hideEnvironment) {
				this.displayType = displayType;
				this.isLogical = isLogical;
				this.infoCacheId = infoCacheId;
				this.hideEnvironment = hideEnvironment;
				this.nameSuffix = "";
				
				if (nameSuffix) {
					this.nameSuffix = nameSuffix;
					
					var envLabel = this.getDescendantOfName("environmentLabel");
					envLabel.setName(envLabel.getName() + nameSuffix);
					
					var modeLabel = this.getDescendantOfName("modeLabel");
					modeLabel.setName(modeLabel.getName() + nameSuffix);
					
					var imgEnvLbl = this.getDescendantOfName("imgEnvLbl");
					imgEnvLbl.setName(imgEnvLbl.getName() + nameSuffix);
					
					var breadCrumbTrailLabel1 = this.getDescendantOfName("breadCrumbTrailLabel1");
					breadCrumbTrailLabel1.setName(breadCrumbTrailLabel1.getName() + nameSuffix);
					
					var breadCrumbTrailLabel2 = this.getDescendantOfName("breadCrumbTrailLabel2");
					breadCrumbTrailLabel2.setName(breadCrumbTrailLabel2.getName() + nameSuffix);
					
					var imgBCTrailLbl1 = this.getDescendantOfName("imgBCTrailLbl1");
					imgBCTrailLbl1.setName(imgBCTrailLbl1.getName() + nameSuffix);
					
					var imgBCTrailLbl2 = this.getDescendantOfName("imgBCTrailLbl2");
					imgBCTrailLbl2.setName(imgBCTrailLbl2.getName() + nameSuffix);
				}

				tibco.admin.monitormanage.general.PageBusUtils.subscribe(infoCacheSubject, this.handleDisplayScreen, this);
			}

			plugin.prototype.handleDisplayScreen = function(subject, message, breadcrumbObj) {
				breadcrumbObj.loadContent(breadcrumbObj);
			}

			plugin.prototype.loadContent = function(breadcrumbObj) {
				var infoDoc = tibco.admin.Main.getServer().Cache.getDocument(breadcrumbObj.infoCacheId);

				if(infoDoc)
				{
					breadcrumbObj.contentLoaded = true;
					var imgEnvLbl = breadcrumbObj.getDescendantOfName("imgEnvLbl" + breadcrumbObj.nameSuffix);
					var imgEnvSrc = "jsxaddin://user!MatrixAdmin/images/matrix/environment.gif";

					if(breadcrumbObj.displayType == plugin.displayTypeService)
					{
						record = infoDoc.getFirstChild();

						// set the environment
						if(!breadcrumbObj.hideEnvironment)
						{
							var envLabel = breadcrumbObj.getDescendantOfName("environmentLabel" + breadcrumbObj.nameSuffix);
							imgEnvLbl.setSrc(imgEnvSrc);
							//imgEnvLbl.repaint();
							var envText = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showEnvironmentDetail('" + record.getAttribute("environmentKey") + "','" + breadcrumbObj.isLogical + "');\">" + record.getAttribute("environmentName") + "</a>";
							envLabel.setText(envText);
							//envLabel.repaint();
						}

						// set the mode label
						var modeLabel = breadcrumbObj.getDescendantOfName("modeLabel" + breadcrumbObj.nameSuffix);
						var modeText;
						if(breadcrumbObj.isLogical)
						{ modeText = plugin.logicalLabelText; }
						else
						{ modeText = plugin.physicalLabelText; }
						modeLabel.setText(modeText);
						//modeLabel.repaint();

						// set the breadcrumb trail
						var breadcrumbLabel1 = breadcrumbObj.getDescendantOfName("breadCrumbTrailLabel1" + breadcrumbObj.nameSuffix);
						var breadcrumbLabel2 = breadcrumbObj.getDescendantOfName("breadCrumbTrailLabel2" + breadcrumbObj.nameSuffix);
						var imgBCTrailLbl1 = breadcrumbObj.getDescendantOfName("imgBCTrailLbl1" + breadcrumbObj.nameSuffix);
						var imgBCTrailLbl2 = breadcrumbObj.getDescendantOfName("imgBCTrailLbl2" + breadcrumbObj.nameSuffix);
						var imgBCTrailLblSrc1 = "";
						var imgBCTrailLblSrc2 = "";
						var breadcrumbText1, breadcrumbText2;

						if(breadcrumbObj.isLogical)
						{
							imgBCTrailLblSrc1 = "jsxaddin://user!MatrixAdmin/images/matrix/service_assembly.gif";
							imgBCTrailLblSrc2 = "jsxaddin://user!MatrixAdmin/images/matrix/service_unit.gif";
							breadcrumbText1 = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showServiceAssemblyDetail('" + record.getAttribute("serviceAssemblyKey") + "');\">" + record.getAttribute("serviceAssemblyName") + "</a>";
							breadcrumbText2 = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showServiceUnitDetail('" + record.getAttribute("serviceUnitKey") + "');\">" + record.getAttribute("serviceUnitName") + "</a>";
						}
						else
						{
							imgBCTrailLblSrc1 = "jsxaddin://user!MatrixAdmin/images/matrix/machines.gif";
							imgBCTrailLblSrc2 = "jsxaddin://user!MatrixAdmin/images/matrix/node.gif";
							breadcrumbText1 = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showMachineDetail('" + record.getAttribute("machineKey") + "');\">" + record.getAttribute("machineName") + "</a>";
							breadcrumbText2 = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showNodeDetail('" + record.getAttribute("nodeKey") + "');\">" + record.getAttribute("nodeName") + "</a>";
						}
						breadcrumbLabel1.setText(breadcrumbText1);
						breadcrumbLabel2.setText(breadcrumbText2);
						imgBCTrailLbl1.setSrc(imgBCTrailLblSrc1);
						imgBCTrailLbl2.setSrc(imgBCTrailLblSrc2);
						//imgBCTrailLbl1.repaint();
						//imgBCTrailLbl2.repaint();
						//breadcrumbLabel1.repaint();
						//breadcrumbLabel2.repaint();

					}
					else if(breadcrumbObj.displayType == plugin.displayTypeServiceAssembly)
					{
						record = infoDoc.getFirstChild();

						// set the environment
						var envLabel = breadcrumbObj.getDescendantOfName("environmentLabel" + breadcrumbObj.nameSuffix);
						imgEnvLbl.setSrc(imgEnvSrc);
						//imgEnvLbl.repaint();
						var envText = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showEnvironmentDetail('" + record.getAttribute("environmentKey") + "','" + breadcrumbObj.isLogical + "');\">" + record.getAttribute("environmentName") + "</a>";
						envLabel.setText(envText);
						//envLabel.repaint();
					}
					else if(breadcrumbObj.displayType == plugin.displayTypeServiceUnit)
					{
						var imgBCTrailLbl = breadcrumbObj.getDescendantOfName("imgBCTrailLbl1" + breadcrumbObj.nameSuffix);
						var imgBCTrailLblSrc = "";
						record = infoDoc.getFirstChild();

						// set the environment
						var envLabel = breadcrumbObj.getDescendantOfName("environmentLabel" + breadcrumbObj.nameSuffix);
						imgEnvLbl.setSrc(imgEnvSrc);
						//imgEnvLbl.repaint();
						var envText = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showEnvironmentDetail('" + record.getAttribute("environmentKey") + "','" + breadcrumbObj.isLogical + "');\">" + record.getAttribute("environmentName") + "</a>";
						envLabel.setText(envText);
						//envLabel.repaint();

						// set the mode label
						var modeLabel = breadcrumbObj.getDescendantOfName("modeLabel" + breadcrumbObj.nameSuffix);
						modeLabel.setText(plugin.logicalLabelText);
						//modeLabel.repaint();

						// set the breadcrumb trail
						imgBCTrailLblSrc = "jsxaddin://user!MatrixAdmin/images/matrix/service_assembly.gif";
						var breadcrumbLabel = breadcrumbObj.getDescendantOfName("breadCrumbTrailLabel1" + breadcrumbObj.nameSuffix);
						var breadcrumbText = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showServiceAssemblyDetail('" + record.getAttribute("serviceAssemblyKey") + "');\">" + record.getAttribute("serviceAssemblyName") + "</a>";
						breadcrumbLabel.setText(breadcrumbText);
						imgBCTrailLbl.setSrc(imgBCTrailLblSrc);
						//imgBCTrailLbl.repaint();
						//breadcrumbLabel.repaint();
					}
					else if(breadcrumbObj.displayType == plugin.displayTypeNode)
					{
						var imgBCTrailLbl = breadcrumbObj.getDescendantOfName("imgBCTrailLbl1" + breadcrumbObj.nameSuffix);
						var imgBCTrailLblSrc = "";
						record = infoDoc.getFirstChild();

						// set the environment
						var envLabel = breadcrumbObj.getDescendantOfName("environmentLabel" + breadcrumbObj.nameSuffix);
						imgEnvLbl.setSrc(imgEnvSrc);
						//imgEnvLbl.repaint();
						var envText = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showEnvironmentDetail('" + record.getAttribute("environmentKey") + "','" + breadcrumbObj.isLogical + "');\">" + record.getAttribute("environmentName") + "</a>";
						envLabel.setText(envText);
						//envLabel.repaint();

						// set the mode label
						var modeLabel = breadcrumbObj.getDescendantOfName("modeLabel" + breadcrumbObj.nameSuffix);
						modeLabel.setText(plugin.physicalLabelText);
						//modeLabel.repaint();

						// set the breadcrumb trail
						imgBCTrailLblSrc = "jsxaddin://user!MatrixAdmin/images/matrix/machines.gif";
						var breadcrumbLabel = breadcrumbObj.getDescendantOfName("breadCrumbTrailLabel1" + breadcrumbObj.nameSuffix);
						var breadcrumbText = "<a style=\"color:#257792;\" href=\"javascript:tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.showMachineDetail('" + record.getAttribute("machineKey") + "');\">" + record.getAttribute("machine") + "</a>";
						breadcrumbLabel.setText(breadcrumbText);
						imgBCTrailLbl.setSrc(imgBCTrailLblSrc);
						//imgBCTrailLbl.repaint();
						//breadcrumbLabel.repaint();
						
					}
					breadcrumbObj.repaint();
				}
			}

			plugin.showEnvironmentDetail = function(envId, isLogical) {
				var paramArray = { environmentId:envId };
				var screenId = tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.environmentScreenId;
				if(isLogical)
				{ screenId = tibco.admin.monitormanage.uicomponents.page.deployment.Deployment.environmentScreenId; }
				tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(screenId, paramArray);
			}
			plugin.showServiceAssemblyDetail = function(serviceAssemblyIdVal) {
				var paramArray = { serviceAssemblyId:serviceAssemblyIdVal };
				tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(tibco.admin.monitormanage.uicomponents.page.deployment.Deployment.serviceAssemblyScreenId, paramArray);
			}
			plugin.showServiceUnitDetail = function(serviceUnitIdVal) {
				var paramArray = { serviceUnitId:serviceUnitIdVal };
				tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(tibco.admin.monitormanage.uicomponents.page.deployment.Deployment.serviceUnitScreenId, paramArray);
			}
			plugin.showMachineDetail = function(machineIdVal) {
				var paramArray = { machineId:machineIdVal };
				tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.machineScreenId, paramArray);
			}
			plugin.showNodeDetail = function(nodeIdVal) {
				var paramArray = { nodeId:nodeIdVal };
				tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.nodeScreenId, paramArray);
			}

		});